$(document).ready(function(){
	$("form").submit(function(){
		$("input[name='title']+span,textarea[name='content']+span").css("display","none");
		$.post("AddNews.do",$("form").serialize(),function(result){
			result = eval('(' + result + ')');
			if(result != undefined && result != null){
				if(result.status != undefined && result.status != null){
					if(result.status == 'ok'){
						alert("添加新闻成功");
						window.location.href="ListNews.do";
						return false;
					}else if(result.status == 'error'){
						alert(result.msg);
					}
				}
				if(result.title != undefined && result.title != null){
					$("input[name='title']+span").css("display","inline-block");
					$("input[name='title']+span").html("<i class=\"icon iconfont\">&#xe624;</i>" + result.title);
				}
				if(result.content != undefined && result.content != null){
					$("input[name='content']+span").css("display","inline-block");
					$("textarea[name='content']+span").html("<i class=\"icon iconfont\">&#xe624;</i>" + result.content);
				}
			}else{
				alert("系统错误");
			}
		});
		return false;
	});
})